import request from '@/utils/request'

/**
 * 新建编辑
 * @param {*} data
 */
export function crmCustomerVipSaveAPI(data) {
  const url = data.entity && data.entity.studentId ? 'update' : 'add'
  return request({
    url: 'crmCustomerVip/' + url,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 列表
 * @param {*} data
 */
export function crmCustomerVipIndexAPI(data) {
  return request({
    url: 'crmCustomerVip/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 删除
 * @param {*} data
 */
export function crmCustomerVipDeleteAPI(data) {
  return request({
    url: 'crmCustomerVip/deleteByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 详情
 */
export function crmCustomerVipReadAPI(data) {
  return request({
    url: `crmCustomerVip/queryById/${data.customerId}`,
    method: 'post',
    data: data
  })
}

// 操作
/**
 * 学员锁定，解锁
 * @param {*} data
 */
export function crmCustomerVipLockAPI(data) {
  return request({
    url: 'crmCustomerVip/lock',
    method: 'post',
    data: data
  })
}

/**
 * 学员放入公海
 * @param {*} data
 * customer_id 	学员数组
 */
export function crmCustomerVipPutInPoolAPI(data) {
  return request({
    url: 'crmCustomerVip/updateCustomerByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员转移
 * @param {*} data
 */
export function crmCustomerVipTransferAPI(data) {
  return request({
    url: 'crmCustomerVip/changeOwnerUser',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员转移助教协作人
 * @param {*} data
 */
 export function crmCustomerVipChangeAPI(data) {
  return request({
    url: 'crmCustomerVip/changeAssistantUser',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员导出
 * @param {*} data
 * customer_id 学员ID
 */
export function crmCustomerVipExcelExportAPI(data) {
  return request({
    url: 'crmCustomerVip/batchExportExcel',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}

/**
 * 全部导出
 * @param {*} data
 */
export function crmCustomerVipExcelAllExportAPI(data) {
  return request({
    url: 'crmCustomerVip/allExportExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员导入
 * @param {*} data
 * customer_id 学员ID
 */
export function crmCustomerVipExcelImportAPI(data) {
  var param = new FormData()
  Object.keys(data).forEach(key => {
    param.append(key, data[key])
  })
  return request({
    url: 'crmCustomerVip/uploadExcel',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}


/**
 * 学员导入模板下载
 * @param {*} data
 *
 */
export const crmCustomerVipExcelDownloadURL = process.env.BASE_API + 'crmCustomerVip/downloadExcel'
export function crmCustomerVipDownloadExcelAPI(data) {
  return request({
    url: 'crmCustomerVip/downloadExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}


/**
 * 学员分配
 * @param {*} data
 */
export function crmCustomerVipDistributeAPI(data) {
  return request({
    url: 'crmCustomerVip/distributeByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员领取
 * @param {*} data
 */
export function crmCustomerVipReceiveAPI(data) {
  return request({
    url: 'crmCustomerVip/receiveByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下联系人
 * @param {*} data
 */
export function crmCustomerVipQueryContactsAPI(data) {
  return request({
    url: 'crmCustomerVip/queryContacts',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下回访
 * @param {*} data
 */
export function crmCustomerVipQueryVisitAPI(data) {
  return request({
    url: 'crmCustomerVip/queryReturnVisit',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下商机
 * @param {*} data
 */
export function crmCustomerVipQueryBusinessAPI(data) {
  return request({
    url: 'crmCustomerVip/queryBusiness',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下合同
 * @param {*} data
 */
export function crmCustomerVipQueryContractAPI(data) {
  return request({
    url: 'crmCustomerVip/queryContract',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下回款计划
 * @param {*} data
 */
export function crmCustomerVipQueryReceivablesPlanAPI(data) {
  return request({
    url: 'crmCustomerVip/queryReceivablesPlan',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 学员下回款
 * @param {*} data
 */
export function crmCustomerVipQueryReceivablesAPI(data) {
  return request({
    url: 'crmCustomerVip/queryReceivables',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 团队操作
/**
 * 团队成员创建
 * @param {*} data
 * types crm_leads
 * typesId 分类ID
 */
export function crmCustomerVipSettingTeamSaveAPI(data) {
  return request({
    url: 'crmCustomerVip/addMembers',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function crmCustomerVipSettingTeamDeleteAPI(data) {
  return request({
    url: 'crmCustomerVip/deleteMembers',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function crmCustomerVipTeamMembersAPI(data) {
  return request({
    url: `crmCustomerVip/getMembers/${data.id}`,
    method: 'post'
  })
}

export function crmCustomerVipUpdateMembersAPI(data) {
  return request({
    url: 'crmCustomerVip/updateMembers',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 退出团队
 * @param {*} data
 */
export function crmCustomerVipExitTeamAPI(data) {
  return request({
    url: `crmCustomerVip/exitTeam/${data.id}`,
    method: 'post'
  })
}

/**
 * 学员成交状态修改
 * @param {*} data
 * id 学员IDs
 */
export function crmCustomerVipDealStatusAPI(data) {
  return request({
    url: 'crmCustomerVip/setDealStatus',
    method: 'post',
    data: data
  })
}

/**
 * 设置首要联系人
 * @param {*} data
 *
 */
export function crmCustomerVipSetContactsAPI(data) {
  return request({
    url: 'crmCustomerVip/setContacts',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 数据查重
 * @param {*} data
 *
 */
export function crmCustomerVipDataCheckAPI(data) {
  return request({
    url: 'crmCustomerVip/dataCheck',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 附件列表
 * @param {*} data
 *
 */
export function crmCustomerVipFileListAPI(data) {
  return request({
    url: 'crmCustomerVip/queryFileList',
    method: 'post',
    data: data
  })
}

/**
 * tab数量
 * @param {*} data
 *
 */
export function crmCustomerVipNumAPI(data) {
  return request({
    url: 'crmCustomerVip/num',
    method: 'post',
    data: data
  })
}

/**
 * 学员标星
 * @param {*} data
 *
 */
export function crmCustomerVipStarAPI(data) {
  return request({
    url: `crmCustomerVip/star/${data.id}`,
    method: 'post'
  })
}

/**
 * 发票信息
 * @param {*} data
 */
export function crmCustomerVipInvoiceAPI(data) {
  return request({
    url: 'crmCustomerVip/queryInvoice',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 删除发票信息
 * @param {*} data
 */
export function crmCustomerVipInvoiceInfoAPI(data) {
  return request({
    url: 'crmCustomerVip/queryInvoiceInfo',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


/**
 * 查询batchId
 * @param {*} data
 */
export function crmQueryBatchIdsByIdsAPI(data) {
  return request({
    url: 'crmCustomerVip/queryBatchIdsByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 更新学员状态
 * @param {*} data
 */
export function crmUpdateStudentStatusByIdsAPI(data) {
  return request({
    url: 'crmCustomerVip/updateStudentStatus',
    method: 'post',
    data: data,
    // headers: {
    //   'Content-Type': 'application/json;charset=UTF-8'
    // }
  })
}
// 变更风险标签 
export function updateRiskLabel(data) {
  return request({
    url: 'crmCustomerVip/updateRiskLabel',
    method: 'post',
    data: data,
  })
}
/**
 * vip学员下退款
 * @param {*} data
 */
export function crmCustomerVipRefundAPI(data) {
  return request({
    url: 'crmCustomerVip/queryRefund',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
